<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="jquery-3.6.0.min.js"></script>
		<script>
		$(function(){
			$("#btn").click(function(){//给提交按钮添加单击事件
			//获取账号和密码
			var name=$("#name").val();
			var pwd=$("#pwd").val();
				$.ajax({
				url:"CustomerServlet",
				method:"post",
				data:{"method":"login","c_name":name,"c_pass":pwd},
				dataType:"json",
				success:function(result){
					$("#msg").html(result.msg);
				// 	console.log(result.code);
				// 	if(result.code==200){
				// 		//登陆成功，获取token，显示在span
				// 		$("#msg").html(result.token);
				// 	}else{result.code==500}
				// 	$("#msg").html(result.msg);
				}
				})
			})
		})
		</script>
</head>
<body>
<span id="msg"></span>
		<br>
		<form action="" method="post" onSubmit="return false">
			账号:<input type="text" id="name" value=""><br>
			密码:<input type="password" id="pwd" value=""><br>
			<button id="btn">提交</button>
			</form>
</body>
</html>